package handler;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created with IntelliJ IDEA.
 * User: zhangyong
 * Date: 13-7-23
 * Time: 下午10:07
 * To change this template use File | Settings | File Templates.
 */
public class MemcachedHandler extends IoHandlerAdapter {

    private static Logger logger = LoggerFactory.getLogger(MemcachedHandler.class);

    public void sessionCreated(IoSession session) throws Exception {
        logger.info("sessionCreated");
    }

    public void sessionOpened(IoSession session) throws Exception {
        logger.info("sessionOpened");
    }

    public void sessionClosed(IoSession session) throws Exception {
        logger.warn("sessionClosed");
    }

    public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
         logger.info("sessionIdle");
    }

    public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
        if (logger.isWarnEnabled()) {
            logger.warn("EXCEPTION, please implement " + getClass().getName()
                    + ".exceptionCaught() for proper handling:", cause);
        }
    }

    public void messageReceived(IoSession session, Object message) throws Exception {
         logger.info("messageReceived");
    }

    public void messageSent(IoSession session, Object message) throws Exception {
        logger.info("messageSent");
    }


}
